import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  // 添加数据
  state: {
    navList: [
      // {text:"主页",id:1,path:"/home"},
    ],
    maxWidth:"100%",
    fontSize:"16px",
    fontFamily:"Arial, Helvetica, sans-serif"
  },
  getters: {
  },
  mutations: {
    // 关闭Tab窗口
    closeTab(state,arr){
         state.navList = arr;
    },
    // 添加Tab窗口
    addTab(state,route){
       let arr = state.navList ||  [];
      //  console.log(arr);
       let text = route.meta.title;
       let isHave = arr.some(item=> item.text == text)
       if(isHave){
          return false;
       }
      //  console.log(route);
       arr.push({
         id: Symbol(),
         text: text,
         path: route.path
       })
       state.arr = arr;// 赋值
    },
    // 改变界面宽度
    changeMaxWidth(state,value){
        state.maxWidth = value;
    },
    // 改变界面字体大小
    changeFontSize(state,value){
        state.fontSize = value;
    },
    // 改变界面字体类型
    changeFontFamily(state,value){
        state.fontFamily = value;
    }
  },
  actions: {
  },
  modules: {
  }
})
